package com.ks.pc.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ks.dto.BannerImgDto;
import com.ks.dto.ImgDto;
import com.ks.pc.dao.DaoSupport;
import com.ks.pc.service.SysBannerService;

@Service("sysBannerService")
public class SysBannerServiceImpl implements SysBannerService {

	public static final Logger logger = Logger.getLogger(SysProductServiceImpl.class);

	@Autowired
	private DaoSupport daoSupport;

	public List<ImgDto> findSlidePhoto() {
		try {
			return daoSupport.findForList("BannerMapper.findSlidePhoto", null);
		} catch (Exception e) {
			logger.debug(e.getMessage());
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.ks.pc.service.SysBannerService#getClassifyImgs(java.lang.String)
	 */
	public List<String> getClassifyImgs(Integer classifyId) {
		try {
			return daoSupport.findForList("BannerMapper.getClassifyImgs", classifyId);
		} catch (Exception e) {
			logger.debug(e.getMessage());
		}
		return null;
	}
	
	public Integer insertBannerImgDto(BannerImgDto dto) {
		try {
			Object pkId = daoSupport.save("BannerMapper.insertBannerImgDto", dto);
			return Integer.parseInt(pkId.toString());
		} catch (Exception e) {
			logger.debug(e.getMessage());
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.ks.pc.service.SysBannerService#deleteBannerImgDto(java.lang.Integer)
	 */
	@Override
	public Integer deleteBannerImgDto(Integer classifyId) {
		try {
			Object pkId = daoSupport.delete("BannerMapper.deleteBannerImgDto", classifyId);
			return Integer.parseInt(pkId.toString());
		} catch (Exception e) {
			logger.debug(e.getMessage());
		}
		return null;
	}
	
	@Override
	public List<ImgDto> findSlidePhotoByClassifyId(Integer classifyId) {
		try {
			return daoSupport.findForList("BannerMapper.findSlidePhotoByClassifyId", classifyId);
		} catch (Exception e) {
			logger.debug(e.getMessage());
		}
		return null;
	}
}
